@extends('layouts.mobile')

@section('title', '绑定邮箱')

@section('content')
    <div class="security">
        <form class="form">
            <div class="form-group">
                <input type="email" id="email" class="form-control" placeholder="请输入邮箱地址">
            </div>
            <div class="blank"></div>
            <div class="form-group">
                <button type="button" id="submitButton" class="btn btn-lg btn-primary">绑定</button>
            </div>
        </form>
    </div>
@stop

@section('foot')
    <script type="text/javascript">
        $("#submitButton").on('tap', function () {
            var email = $("#email").val();
            if (!DSXValidate.IsEmail(email)){
                DSXUI.showToast('邮箱地址输入错误, 请重新输入');
                return false;
            }

            $.ajax({
                type:'POST',
                url:'/mobile/security/setemail',
                data:{email:email, formsubmit:'yes'},
                success:function (response) {
                    if (response.errcode) {
                        DSXUI.showToast(response.errmsg);
                    } else {
                        DSXUI.showToast('邮箱地址绑定成功', 1500, function () {
                            window.history.go(-1);
                        });
                    }
                }
            })
        });
    </script>
@stop
